package com.study.spring.ioc.circulardependencies.complex;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;

public class JdkProxyBeanPostProcessor implements SmartInstantiationAwareBeanPostProcessor {

    public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {

        // 假设:A 被切点命中 需要创建代理  @PointCut("execution(* *..InstanceA.*(..))")
        if(bean instanceof InstanceA) {
            JdkDynimcProxy jdkDynimcProxy = new JdkDynimcProxy(bean);
            return  jdkDynimcProxy.getProxy();
        }

        return bean;
    }
}
